{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>编辑产品</h5>
                </div>
                <div class="ibox-content layui-form">
                    <div class="layui-row layui-col-space10 layui-form-item">

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">产品名称：</label>
                            <div class="layui-input-block">
                                <input type="text" name="pp_name" lay-verify="required" placeholder="产品名称" class="layui-input" value="{$product.pp_name}">
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">产品首图：</label>
                            <input type="hidden" name="pp_image" id="lay-img" lay-verify="image" value="{$product.pp_image}">
                            <div class="layui-input-block">
                                <div id="lay-upload">上传图片</div>
                                <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                                    预览图：
                                    <div class="layui-upload-list" id="lay-list">
                                        <img class="layui-append-img" src="{$product.pp_image}" onerror="this.src='/static/admin/images/no_img.jpg'">
                                    </div>
                                </blockquote>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8 form-group">
                            <label class="layui-form-label">状态：</label>
                            <div class="layui-input-block">
                                <input type="radio" name="pp_status" value="1" class="layui-input" title="上架" {$product.pp_status == 1 ? 'checked' : ''}/>
                                <input type="radio" name="pp_status" value="2" class="layui-input" title="下架" {$product.pp_status == 2 ? 'checked' : ''}/>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">所属套餐：</label>
                            <div class="layui-input-block">
                                <select name="pp_ps_id"  xm-select="select" xm-select-search="" xm-select-radio="" xm-select-search-type="dl">
                                    {foreach name="setmeal" item="vo"}
                                    <option value="{$vo.ps_id}" {$vo.ps_id == $product.pp_ps_id ? 'selected' : ''}>{$vo.ps_name}</option>
                                    {/foreach}
                                </select>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">产品价格：</label>
                            <div class="layui-input-block">
                                <input type="text" name="pp_price" lay-verify="required" placeholder="产品价格" class="layui-input" oninput="value=value.replace(/[^\d.]+/g,'')" value="{$product.pp_price}">
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">产品规格：</label>
                            <div class="layui-input-block">
                                <input type="text" name="pp_spec" lay-verify="required" placeholder="例如：10ml" class="layui-input" value="{$product.pp_spec}">
                            </div>
                        </div>

                        <input type="hidden" value="{$pp_id}" name="pp_id">

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit="" lay-filter="component-form-element">保存
                                </button>
                                <button class="layui-btn layui-btn-primary" onclick="history.go(-1)">关闭</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

{include file="public/footer" /}
<script>
    wk.uploadImg({size:5,type:'png,jpg,jpeg',url:"{:url('Upload/upload')}",domain:""});
    layui.use(['form','upload','layedit','laydate'], function() {
        var form = layui.form;

        form.on('submit(component-form-element)', function (data) {
            $('.layui-btn').addClass('layui-disabled').attr('disabled','disabled');
            $.ajax({
                url:"{:url('productEdit')}",
                type:'post',
                dataType:'json',
                data:data.field,
                success:function(res){
                    if (res.code == 200) {
                        wk.success(res.msg,"{:url('Privateproduct/index')}");
                    } else {
                        wk.error(res.msg,'','$(".layui-btn").removeClass(\'layui-disabled\').removeAttr(\'disabled\');');
                    }
                }
            });
        });
    });
</script>

</body>
</html>